Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint to transcribe videos #554

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

Endpoint to transcribe videos #554

wants to merge 32 commits into from

Conversation

ekrojo77
Copy link
Contributor

@ekrojo77 ekrojo77 commented Dec 5, 2024

  • Testing
  • Endepunkt for å polle om filen er opprettet
  • Bedre return fra GET

case Success(_) => Right(())
case Failure(ex) => returnLeftError(ex)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beholder disse i første omgang før vi vet hva som trengs av endepunkt. Men tror det rene transcribe-endepunktet er det som vil bli mest brukt

@ekrojo77 ekrojo77 marked this pull request as ready for review December 13, 2024 10:37
@ekrojo77 ekrojo77 requested a review from a team December 13, 2024 10:37
@ekrojo77 ekrojo77 marked this pull request as draft December 13, 2024 13:53
@ekrojo77 ekrojo77 changed the title Endpoint to extract audio from brightcove files Endpoint to transcribe videos Dec 13, 2024
@ekrojo77 ekrojo77 marked this pull request as ready for review December 16, 2024 10:43
@ekrojo77 ekrojo77 marked this pull request as draft December 17, 2024 13:19
Copy link
Member

@gunnarvelle gunnarvelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lisenspirk

@ekrojo77 ekrojo77 marked this pull request as ready for review January 2, 2025 10:38
@ekrojo77 ekrojo77 requested a review from jnatten January 8, 2025 06:40
def getVideoTranscription(
videoId: String,
language: String
): Try[Either[String, String]] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeg synes fortsatt det er vanskelig å vite hva denne typen representerer uten å dykke ned i hva funksjonen gjør og returnerer.

Kanskje vi kunne brukt en trait som enten kunne være success eller ikke?
Noe sånt?

sealed trait TranscriptionResult
case class TranscriptionComplete(transcription: String) extends TranscriptionResult
case class TranscriptionNonComplete(transcriptionStatus: String) extends TranscriptionResult

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da kan vi gjøre feks sånn:

  getObjectFromS3(transcribeUri).map(TranscriptionComplete)
} else {
  Success(TranscriptionNonComplete(transcriptionJobStatus))


transcribeClient.getTranscriptionJob(jobName).flatMap { transcriptionJobResponse =>
val transcriptionJob = transcriptionJobResponse.transcriptionJob()
val transcriptionJobStatus = transcriptionJob.transcriptionJobStatus().toString
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denne trenger vel egentlig ikke konverteres til en streng?

Comment on lines +33 to +42
val authResponse = request.send(backend)
Try {
authResponse.body match {
case Right(jsonString) =>
decode[TokenResponse](jsonString) match {
case Right(tokenResponse) => tokenResponse.access_token
case Left(error) => throw new Exception(s"Failed to decode token response: ${error.getMessage}")
}
case Left(error) => throw new Exception(s"Failed to get token: ${error}")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.send(backend) kan potensielt kaste exception så den burde nok være med i Try'en, kanskje noe sånt?

Suggested change
val authResponse = request.send(backend)
Try {
authResponse.body match {
case Right(jsonString) =>
decode[TokenResponse](jsonString) match {
case Right(tokenResponse) => tokenResponse.access_token
case Left(error) => throw new Exception(s"Failed to decode token response: ${error.getMessage}")
}
case Left(error) => throw new Exception(s"Failed to get token: ${error}")
}
Try(request.send(backend).body) match {
case Success(Right(jsonString)) =>
decode[TokenResponse](jsonString) match {
case Right(tokenResponse) => Success(tokenResponse.access_token)
case Left(error) => Failure(new Exception(s"Failed to decode token response: ${error.getMessage}"))
}
case Success(Left(error)) => Failure(new Exception(s"Failed to get token: ${error}"))
case Failure(ex) => Failure(ex)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideelt sett så burde vi sikkert lage noen spesifikke Exception typer og (eller gjenbruke om vi har noen som finnes allerede)

Comment on lines +55 to +69
val response = request.send(backend)
Try {
response.body match {
case Right(jsonString) =>
parse(jsonString) match {
case Right(json) =>
json.asArray match {
case Some(videoSources) => videoSources
case None => throw new Exception("Failed to parse video source")
}
case Left(error) => throw new Exception(s"Failed to parse video source: ${error.getMessage}")
}
case Left(error) => throw new Exception(s"Failed to get video source: ${error}")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Samme her:

Suggested change
val response = request.send(backend)
Try {
response.body match {
case Right(jsonString) =>
parse(jsonString) match {
case Right(json) =>
json.asArray match {
case Some(videoSources) => videoSources
case None => throw new Exception("Failed to parse video source")
}
case Left(error) => throw new Exception(s"Failed to parse video source: ${error.getMessage}")
}
case Left(error) => throw new Exception(s"Failed to get video source: ${error}")
}
}
Try(request.send(backend).body) match {
case Success(Right(jsonString)) =>
parse(jsonString) match {
case Right(json) =>
json.asArray match {
case Some(videoSources) => Success(videoSources)
case None => Failure(new Exception("Failed to parse video source"))
}
case Left(error) => Failure(new Exception(s"Failed to parse video source: ${error.getMessage}"))
}
case Success(Left(error)) => Failure(new Exception(s"Failed to get video source: ${error}"))
case Failure(ex) => Failure(ex)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants